package fr.emn.integration.synthese.controle;

import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JButton;

import fr.emn.integration.synthese.abstraction.Cours;
import fr.emn.integration.synthese.presentation.EvaluationDialog;
import fr.emn.integration.synthese.presentation.GroupeDialog;

public class ControlJButtonEditEvaluation implements Observer,ActionListener{
	
	private Cours modele;
	private JButton button;
	private Frame parent;

	public ControlJButtonEditEvaluation(Frame parent, Cours modele, JButton button) {
		this.modele = modele;
		this.button = button;
		this.parent = parent;
		button.setEnabled(false);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		EvaluationDialog evaluationDialog = new EvaluationDialog(parent, modele, false);
		evaluationDialog.setVisible(true);
	}

	@Override
	public void update(Observable o, Object message) {
		Integer iMessage = (Integer) message;
		if (iMessage == Cours.CHANGEMENT_EVALUATION_COURANT) {
			if (modele.getEvaluationCourante() == -1)
				button.setEnabled(false);
			else
				button.setEnabled(true);
		}
	}

}


